<?php
/**
 * 会员后台控制器
 * 
 * @version $Id: Order.php 352 2012-05-23 09:57:06Z linsir123 $
 */
class controllerOrder extends UserController 
{
	/**
	 * @var 默认的控制器名称
	 */
	public $defaultAction = 'list';
	
	/**
	 * @var 模型
	 */
	public $mOrder;
	
	/**
	 * 构造函数
	 */
	public function __construct()
	{
		parent::__construct();
		
		///
		$this->mOrder = M::order();
	}
	
	/**
	 * 我的订单
	 */
	public function actionList()
	{
		$show = 10;
		$params = array();
		if (isset($_POST['start_date'])) 
			$params['start_date'] = trim($_POST['start_date']);
		if (isset($_POST['end_date'])) 
			$params['end_date'] = trim($_POST['end_date']);
		if (isset($_POST['order_id'])) 
			$params['order_id'] = trim($_POST['order_id']);
		if (isset($_POST['item_title'])) 
			$params['item_title'] = trim($_POST['item_title']);
			
		///
		if ($count = $this->mOrder->getListCount($params)) {
			$page = $this->pagination($show, $count, 'order/list');
			$list = $this->mOrder->getList(($page-1)*$show, $show, $params);
		}
		
		///
		View::assign('list', $list);
		if (Request::isAjax() && Request::isPost()) 
			View::display('_div_order');
		else {
			View::display('order');
			View::assign('curMenu', 'order');
			
			///
			AppView::addCss(
				'javascript/JSCal2-1.9/src/css/jscal2.css',
				'javascript/JSCal2-1.9/src/css/steel/steel.css'
			);
			AppView::addJs(
				'JSCal2-1.9/src/js/jscal2.js',
				'JSCal2-1.9/src/js/lang/cn.js'
			);
		}
	}
}
